In Flutter SizedBox represents a widget of a specified size.
It is used to control the dimensions of the child widget. Container is another Flutter widget, that doesn’t only provide
width and height, but also applies additional constraints, decorations, transformations, etc. Thus Container is a more advanced and at
the same time a much heavier widget. It is recommended to not use it, if the only need is to add a whitespace. SizedBox is a better
option for such simple cases. You can even benefit from a const constructor of a SizedBox, if applicable in your case.
The rule reports issue on the Container instance creation, if:
- both
width and heigh are specified and there are no other parameters except optional key
-
child is specified, at least one of width or heigh is specified and there are no other parameters except
optional key
What is the potential impact?
A misuse of a Container widget may affect you performance and make the layout overly complicated.